#include <stdlib.h>
#include <wiiuse/wpad.h>
#include <fat.h>

#include "coin.h"

#include "coin_png.h"

using namespace std;


Coin::Coin(int x, int y) {
	texCoin = GRRLIB_LoadTexture(coin_png);
	
	PosX = x;
	PosY = y;
	size = 12;
}

Coin::~Coin() {
	GRRLIB_FreeTexture(texCoin);
}

void Coin::SetXY(int x, int y) {
	PosX = x;
	PosY = y;
}
	
bool Coin::Collision(int _x, int _y, int _size) {
	// Player within coin-sprite?
	if ((fix_norm(_x) > (PosX + size)) || (fix_norm(_x) + _size < PosX) || (fix_norm(_y) > PosY + size) || (fix_norm(_y) + _size < PosY)) {
		return false;
	}
	
	return true;
}

void Coin::Render(int scrollx) {
	GRRLIB_DrawImg (PosX - fix_norm(scrollx), PosY, texCoin, 0, 1, 1, GRRLIB_WHITE);
}
